package com.fan.gofast.util.validator;

import org.springframework.util.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 */
public class PhoneNumberValidator implements ConstraintValidator<PhoneNumber, String> {

    @Override
    public boolean isValid(String phoneField, ConstraintValidatorContext constraintValidatorContext) {
        if (StringUtils.isEmpty(phoneField)) {
            return true;
        }

        return PatternUtils.isPhoneNumber(phoneField);
    }
}
